package com.sunkey.service.impl;

import javax.annotation.Resource;

import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;

import com.sunkey.dao.UserDao;
import com.sunkey.domain.User;
import com.sunkey.service.AsyncService;

@Service
public class AsyncServiceImpl implements AsyncService {
    
    @Resource
    private UserDao userDao;

    @Override
    public ListenableFuture<User> getUser(String username) {
        if(username == null){
            throw new RuntimeException("username is null");
        }
        User user = userDao.findUser(username);
        return new AsyncResult<User>(user);
    }

}
